package com.hst.capacity.infra.persistence.jpa.order.express;


import com.hst.capacity.domain.model.entity.order.express.ExpressOrderEntity;
import com.hst.capacity.domain.model.entity.order.express.ExpressOrderHistoryEntity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface ExOrderHistoryRepository extends JpaRepository<ExpressOrderHistoryEntity, String>, JpaSpecificationExecutor<ExpressOrderHistoryEntity> {

    ExpressOrderHistoryEntity findByIdOrder(String IdOrder);

    @Query("select t from ExpressOrderHistoryEntity t where t.externalOrderId = ?1")
    ExpressOrderHistoryEntity findByExternalOrderId(String IdOrder);

    /**
     * 根据运营区域代码查找订单
     * @param regionCode
     * @param pageable
     * @return
     */
    Page<ExpressOrderHistoryEntity> findByRegionCode(String regionCode, Pageable pageable);

    /**
     * 根据司机查找订单
     * @param idDriver
     * @return
     */
    List<ExpressOrderHistoryEntity> findByIdDriver(String idDriver);

}
